#include #include using namespace std; int split(char source[], char destination[][100], char delimitor[]) { char* token; char* context; int tokensFound = 0; token = strtok_s(source,delimitor, &context); while(token != NULL) { strcpy(destination[tokensFound], token); tokensFound++; token = strtok_s(NULL,delimitor, &context); } return tokensFound; } void main() { char s[1000]; char words[1000][100]; cin.getline(s,1000); int wordCount = split(s,words," "); for(int i = 0; i < wordCount; i++) { strcat(words[i], "yay"); } s[0] = '\0'; for(int i = 0; i < wordCount; i++) { strcat(s,words[i]); strcat(s," "); } cout << s << endl; //char s[1000]; //cin.getline(s,1000); //char s2[1000]; //cin.getline(s2,1000); //char* context1; //char*context2; // //char* token = strtok_s(s," ", &context1); //char* token2 = strtok_s(s2," ", &context2); //cout << "'" << token << "'" << endl; //cout << "'" << token2 << "'" << endl; //int i = 0; //while(token != NULL) //{ // if(i%2 ==0) // { // token = strtok_s(NULL," ",&context1); // } // else // { // token = strtok_s(NULL," ",&context2); // } // if(token != NULL) // { // cout << "'" << token << "'" << endl; // } // i++; //} }